package ms.jasim.model.editor.preferences;

import ms.jasim.framework.IConfiguration;
import ms.jasim.model.presentation.JasimEditorPlugin;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FileFieldEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

/**
 * This class represents a preference page that
 * is contributed to the Preferences dialog. By 
 * subclassing <samp>FieldEditorPreferencePage</samp>, we
 * can use the field support built into JFace that allows
 * us to create a page that is small and knows how to 
 * save, restore and apply itself.
 * <p>
 * This page is used to modify preferences only. They
 * are stored in the preference store that belongs to
 * the main plug-in class. That way, preferences can
 * be accessed directly via the preference store.
 */

public class JasimPreferences
	extends FieldEditorPreferencePage
	implements IWorkbenchPreferencePage {

	public JasimPreferences() {
		super(GRID);
		setPreferenceStore(JasimEditorPlugin.getPlugin().getPreferenceStore());
		setDescription("Jasim Paramaters");
		setTitle("Jasim");
	}
	
	/**
	 * Creates the field editors. Field editors are abstractions of
	 * the common GUI blocks needed to manipulate various types
	 * of preferences. Each field editor knows how to save and
	 * restore itself.
	 */
	@Override
	public void createFieldEditors() {
		
		Composite parent = getFieldEditorParent();
		
		addField(new FileFieldEditor("planner", "&Planner Command", false, parent));
		addField(new DirectoryFieldEditor("temp_folder", "&Temporary folder:", parent));
		
		FileFieldEditor templateField = new FileFieldEditor("template", "&Templates", false, parent);
		templateField.setFileExtensions(new String[] {"*.jasim"});
		addField(templateField);
		
		addField(new ComboFieldEditor(IConfiguration.GENERATOR, "&Pddl Generator", 
					new String[][]{
					{"Jasim Organizational Level", "ms.jasim.pddl.JasimOrgPddlGenerator"},
					{"Jasim Indirect Instance Level", "ms.jasim.pddl.JasimIndirectPddlGenerator"},
					{"Bryl's Organizational Level", "ms.jasim.pddl.BrylPddlGenerator"}
				}, parent));
		
		addField(new BooleanFieldEditor(IConfiguration.ADVANCED_MODE, "&Advanced mode", parent));
		
		addField(new BooleanFieldEditor(IConfiguration.USE_NAME_AS_ID, "&Use object name as ID", parent));
		
		addField(new BooleanFieldEditor(IConfiguration.EXPLICIT_DEPENDENCY, "&Explicit dependencies", parent));
		
		addField(new BooleanFieldEditor(IConfiguration.DISPLAY_OBJ_TEXT, "&Display object text", parent));
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
	 */
	public void init(IWorkbench workbench) {
	}
	
}